package com.hsjk.szwj.module.pay.mq.consumer;

import com.hsjk.szwj.framework.mq.core.stream.AbstractStreamMessageListener;
import com.hsjk.szwj.framework.tenant.core.context.TenantContextHolder;
import com.hsjk.szwj.module.pay.dal.dataobject.config.PayOrderDivisionMQ;
import com.hsjk.szwj.module.pay.service.PayOrderDivisionProcessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/09/04 16:04
 **/
@Component
@Slf4j
public class PayOrderDivisionConsumer extends AbstractStreamMessageListener<PayOrderDivisionMQ> {
    @Resource
    private PayOrderDivisionProcessService payOrderDivisionProcessService;

    @Override
    public void onMessage(PayOrderDivisionMQ message) {
        log.info("PayOrderDivisionConsumer:{}", message);
        TenantContextHolder.setTenantId(message.getPayload().getTenantId());
        payOrderDivisionProcessService
                .processPayOrderDivision(message.getPayload().getPayOrderId(),
                        message.getPayload().getUseSysAutoDivisionReceivers(),
                        message.getPayload().getReceiverList(),
                        message.getPayload().getIsResend());
    }
}
